package com.google.code

trait XmlNode {
  val parent: Option[Node]
  val children: List[XmlNode]

  def changeParent(newParent: Option[Node]): XmlNode

  def foldLeft[T](initial: T)(f: (T, XmlNode) => T): T
  def map(f: (XmlNode => XmlNode)): XmlNode = f(this)
  //def filter(f: XmlNode => Boolean): XmlNode

  def foreach(f: XmlNode => Unit): Unit = {
    f(this)
    children foreach (_ foreach f)
  }

  def \(name: String): Option[XmlNode]
  def \\(name: String): List[XmlNode]

}
